<template>
	<view class="container">
		<view class="list">
			<!-- <view class="list-cont" @click="gophere">
				<image class="list-img" src="/static/icon/chuangjianzhibiao.png" mode=""></image>
				<text>{{isphere?$t('my.shezhizjc'):$t('my.chongzhizjc')}}</text>
			</view> -->
			<!-- <view class="list-cont" @click="detal">
				<image class="list-img" src="/static/icon/shanchu.png" mode=""></image>
				<text>删除助记词</text>
			</view> -->
			<view class="list-cont" @click="daochu">
				<image class="list-img" src="/static/icon/daochu.png" mode=""></image>
				<text>{{$t('my.daochuzjc')}}</text>
			</view>
			<view class="list-cont" @click="gomima" v-if="zhifu==='false'">
				<image class="list-img" src="/static/icon/shezhi.png" mode=""></image>
				<text> {{$t('my.shezhimima')}}</text>
			</view>
			<view class="list-cont" @click="gomima2"v-else>
				<image class="list-img" src="/static/icon/shezhi.png" mode=""></image>
				<text> {{$t('my.xiugaimima')}}</text>
			</view>

		</view>
		
	</view>
</template>

<script>
	import {
		Debounce
	} from "@/api/debounce.js"; //防抖
	export default {
		data() {
			return {
				zhifu:false,//支付密码
				zjc:false,
				isphere: true,
				phrase: [],//助记词
				userinfo:{}
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
			  title:  this.$t('shezhi'), // 必填，页面标题）
			 })
			 this.getuserinfo()
			 this.phrase=uni.getStorageSync('phrases')
			
		},
		onShow() {
			 // this.getuserinfo()
		},
		methods: {
			// 获取个人资料
			getuserinfo() {
				let data = {}
				let opts = {
					url: '/user/GetUserInfo',
					method: 'GET'
				};
				this.api.httpTokenRequest(opts, data).then(res => {
					// console.log('个人资料', res);
					if (res[1].data.state == 'success') {
						this.userinfo = res[1].data.list[0]
						this.zhifu=this.userinfo.zfpass
						this.zjc=this.userinfo.zjc
			
					}
			
				})
			},
			// 创建，重置助记词
			// gophere: Debounce(function() {
			// 	this.$tab.navigateTo('/pages/my/zhujici')
			// }, 1000),
			// 删除助记词
			detal(){
				uni.removeStorageSync('phrase');
				this.isphere = true
				this.$modal.msg(this.$t('msg.error8'))
			},
			// 导出助记词
			daochu(){
				var that = this
				uni.setClipboardData({
					data: String(that.phrase),
					success: function() {
						that.$modal.msg(that.$t('msg.error6'))
					},
					fail: function(err) {
						// console.log('复制失败:', err);
					}
				});
			},
			// 支付密码验证
			submitHandle(e) {
			  console.log(e);
			},
			// 设置支付密码
			gomima:Debounce(function(){
				if(this.zjc==="false"&&this.zhifu==="false"){
					this.$tab.navigateTo('/pages/my/zhujici')
				}else if(this.zjc==="true"&&this.zhifu==="false"){
					// console.log('跳转命令已发送');
					this.$tab.navigateTo('/pages/my/yanzengzhuci?type=1')
				}
				
				
			},1000),
			//修改支付密码
			gomima2:Debounce(function(){
				if(this.zjc=="false"&&this.zhifu=="false"){
					this.$tab.navigateTo('/pages/my/zhujici')
				}
				if(this.zjc=="true"&&this.zhifu==="true"){
					this.$tab.navigateTo('/pages/my/yanzengzhuci?type=2')
				}
			},1000)
		},
	}
</script>

<style>
	.container {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.list {
		width: 90%;
		padding: 20rpx;
		background-color: #fff;
		display: flex;
		flex-direction: column;
		color: #000;
		border-radius: 20rpx;
	}

	.list-cont {
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 20rpx;
		font-size: 28rpx;
		font-weight: 500;
		border-bottom: 1rpx solid #d2d2d2;
	}

	.list-cont:active {
		background-color: #ececec;
	}

	.list-img {
		width: 40rpx;
		height: 40rpx;
		margin-right: 15rpx;
	}
</style>